import funcy
import subprocess
import sys
import random
import subprocess
import sys
# import click
# import argparse




# @click.command()
# @click.argument('repeats')
# @click.option('--repeats', default=1, help='Number of repetitions of cardinality.')

def main():
    "put a docstring here"
    track_name = "random_sine_wave_chords.wav"
    repeats = 5 
    
    def cr(nums):
        return "1-" + str(nums - 1)
    
    def er(nums):
        return str(nums)

    nums = 1

    for x in range(repeats):
        nums += 10 
        espeak = ["espeak"]
        espeak.append(er(nums))
    
        subprocess.run(espeak)
    
        rfreqs = [random.randint(20,20000) for i in range(nums)]
        rst = ['sine'] * nums
        sines = zip(rst, rfreqs)
        sines = list(sines)
        sines = list(funcy.flatten(sines))
        sines = [str(x) for x in sines]
        print(sines)
        sines = ["sox", "-r", "44100", "-n", track_name, "synth", "20"] + sines + ["delay", "0", ".05", ".1", "remix"] + ["fade", "5", "-0", "5", "norm", "-24"]
        sines.insert(-6, cr(nums))
        subprocess.run(sines)
    
        play = ["play", track_name]
        subprocess.run(play)


if __name__ == "__main__":
    main()
